import { defineStore } from "pinia";
import defaultSettings from "@/settings";
import { store } from '@/store';

// 导入 Element Plus 中英文语言包
import zhCN from 'ant-design-vue/es/locale/zh_CN';
import en from 'ant-design-vue/es/locale/en_GB';
import { SizeType } from "ant-design-vue/es/config-provider";

// setup
export const useAppStore = defineStore("app", () => {
  // state
  const language = useStorage("language", defaultSettings.language);

  const locale = computed(() => {
    if (language?.value == "en") {
      return en;
    } else {
      return zhCN;
    }
  });

  const size = useStorage<SizeType>("size", defaultSettings.size);

  return {
    language,
    locale,
    size
  };
});

export function useAppStoreHook() {
  return useAppStore(store);
}
